home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c++-part1 / 4451 < prev    next >
Encoding:
Internet Message Format  |  1996-08-06  |  1.7 KB

  1. Path: brazerko.com!Pennywise
  2. From: Pennywise@brazerko.com (Pennywise)
  3. Newsgroups: comp.lang.c++
  4. Subject: Graphics formats
  5. Message-ID: <56a8a984@brazerko.com>
  6. Date: Sat, 27 Jan 96 11:27:00 -0500
  7. Organization: Brazerko Communications
  8.  
  9. I'm working on a graphics program.  I need to be able to save the image on
  10. the screen to a graphics file.  Can anyone help me by supplying either
  11. some code, or the format to any common graphic file type ( PCX, GIF, BMP,
  12. &c )? Here's the code I'm using to manipulate the color palette:
  13.  
  14. typedef struct RGB_color_typ
  15. {
  16.         unsigned char red;
  17.         unsigned char green;
  18.         unsigned char blue;
  19. } RGB_color, *RGB_color_ptr;
  20. #define PALETTE_MASK 0x3c6
  21. #define PALETTE_REGISTER_RD 0x3c7
  22. #define PALETTE_REGISTER_WR 0x3c8
  23. #define PALETTE_DATA 0x3c9
  24. void SetPalette(int index, RGB_color_ptr color)
  25. {
  26.         outp(PALETTE_MASK,0xff);
  27.         outp(PALETTE_REGISTER_WR, index);
  28.         outp(PALETTE_DATA,color->red);
  29.         outp(PALETTE_DATA,color->green);
  30.         outp(PALETTE_DATA,color->blue);
  31. }
  32. void GetPalette(int index, RGB_color_ptr color)
  33. {
  34.         outp(PALETTE_MASK,0xff);
  35.         outp(PALETTE_REGISTER_RD, index);
  36.         color->red   = inp(PALETTE_DATA);
  37.         color->green = inp(PALETTE_DATA);
  38.         color->blue  = inp(PALETTE_DATA);
  39. }
  40.  
  41. I'm using int 10 to set the graphics mode to 0x13, which is 320x200 with
  42. 256 colors.  I'm working exclusively in that mode, for now.
  43.  
  44.  
  45.  
  46. -- 
  47. .-----------------------------------------------------------------------.
  48. | The gateway is Brazerko Communications'; the opinions are the user's. |
  49. | sales@brazerko.com   info@brazerko.com ('bot)   +1 860 886 1441 (BBS) |
  50. `-----------------------------------------------------------------------'
  51.